package com.cs456.TeamBobcat;

import com.cs456.TeamBobcat.database.MyDB;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class WhatDoesThisSayResult extends Activity {
	TextView _resultText;
	Button _homeButton;
	String _path;

	String _result;
	MyDB dba;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.textresult);
		dba = new MyDB(this);
        dba.open();

		initText();
		initHomeButton();
	}

	private void initText() {
		_resultText = (TextView) findViewById(R.id.WAIResult_Text);

		Intent intent = getIntent();
		_result = intent
				.getStringExtra(WebService.WHAT_DOES_THIS_SAY_RESULT_KEY);
		_path = intent.getStringExtra("picPath");
		_resultText.setText(_result);
		dba.insertWDTSphotos(_path,_result);
		dba.close();
	}

	private void initHomeButton() {
		_homeButton = (Button) findViewById(R.id.WAIResult_Home);
		_homeButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				finish();
			}
		});
	}
}
